package com.ruofeng.app.privilege.resource.menu

import com.ruofeng.app.common.ToolkitBean
import org.junit.Test
import org.junit.runner.RunWith
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.data.mongodb.core.query.BasicQuery
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner

/**
 * Created by 邱鹏 on 2017/8/9.
 */
@RunWith(SpringJUnit4ClassRunner::class)
@SpringBootTest
class IndexServiceTest {
    @Autowired lateinit var toolkit: ToolkitBean
    internal var logger: Logger = LoggerFactory.getLogger("PersistenceBeanJTest")
    @Test
    fun getMenu() {
        var query = BasicQuery("{ parentCode : 'node'}")
        var mongoResult = toolkit.mongoTemplate.find(query, Menu::class.java)
        logger.error(toolkit.jsonObjectMapper.writeValueAsString(mongoResult))
    }

    @Test
    fun getMenuByParentcode() {
        var query = BasicQuery("{ parentCode : 'node'}")
        var mongoResult = toolkit.mongoTemplate.find(query, Map::class.java,"menu")
        logger.error(toolkit.jsonObjectMapper.writeValueAsString(mongoResult))
    }

    @Test
    fun getMenuByCode() {
    }

    @Test
    fun createOrUpdateMenu() {
    }

}